<template>
    <div>
        <h1>权益修改页面</h1>
        <table>
            <thead>
                <tr>
                    <td>权益名称</td>
                    <td>
                        <input type="text" v-model="data.QYName">
                    </td>
                </tr>
                <tr>
                    <td>权益状态</td>
                    <td>
                        <input type="checkbox" v-model="data.QYState">勾选表示启用，不勾选表示禁用 
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="修改权益" @click="QyAdd">
                    </td>
                </tr>
            </thead>
        </table>
    </div>
    <a href="/">权益列表</a>
    <br>
    <a href="/Hlist">会员显示列表</a> 
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import axios from 'axios';
import { useRoute, useRouter } from 'vue-router';
//实例化
const router=useRouter();
const route=useRoute();
const data=ref({
  "QYId": 0,
  "QYName": "",
  "QYState": "1"
})
const QyAdd=()=>{
    if(data.value.QYName=="")
    {
        alert("权益名称不能为空");
        return;
    }
    if(data.value.QYState=="")
    {
        alert("权益状态不能为空");
        return;
    }
    axios.put("https://localhost:7258/api/QuanYi/QYUpdate",data.value).then(res=>{
        if(res.data>0)
        {
            alert("权益信息修改成功");
            router.push({path:"/"})
        }
        else
        {
            alert("权益信息修改失败");
        }
    })
}
onMounted(()=>{
    fantian();
})
const fantian=()=>{
    var vid=route.query.id;
    axios.get("https://localhost:7258/api/QuanYi/QYFanTian",{params:{id:vid}}).then(res=>{
        data.value=res.data;
    })
}










</script>

<style scoped>

</style>